package com.quxing.amazon.security;

import org.springframework.security.core.GrantedAuthority;

/**
 * @author zhb
 * @description 自定义权限类, 解决redis反序列化失败问题
 * @date 2020/12/2 15:20
 */
public class CustomGrantedAuthority implements GrantedAuthority {

    private String authority;

    public CustomGrantedAuthority(String authority) {
        this.authority = authority;
    }

    public CustomGrantedAuthority() {
    }

    @Override
    public String getAuthority() {
        return this.authority;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof CustomGrantedAuthority) {
            return this.authority.equals(((CustomGrantedAuthority) obj).authority);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return this.authority.hashCode();
    }

    @Override
    public String toString() {
        return this.authority;
    }
}
